<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        数量:
        <input type="text" id="num" value="1" oninput="changeNum()">
    </div>
    <div>
        单价:
        <input type="text" id="price" value="1" oninput="changePrice()">
    </div>
    <div>
        总计: <span id="total"></span>
    </div>
</body>
<script>
    var num = document.getElementById('num')
    var price = document.getElementById('price')
    var total = document.getElementById('total')
    total.innerText = Number(num.value) * Number(price.value);

    function changeNum(){
        var numVal = numVal(num,value);
        total.innerText = numVal * numVal(price.value)
    }
    function changePrice(){
        var numVal = numVal(price,value);
        total.innerText = numVal(price.value) * priceVal
    }

</script>
</html>